package com.example.yls.demoa;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
    private Button startintentservice;
    private Button startservice;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initBundler();
        startintentserviceEvent();
        startserviceEvent();


    }

    private void startserviceEvent() {
             startservice.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View view) {
                     Intent intent=new Intent();
                     intent.setClass(MainActivity.this,MyFrontService.class);
                     startService(intent);
                 }
             });

    }

    private void startintentserviceEvent() {
       startintentservice.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View view) {
               Intent intent=new Intent();
               intent.setClass(MainActivity.this,MyIntentService.class);
               startService(intent);
           }
       });

    }

    private void initBundler() {
         startintentservice=findViewById(R.id.start_intentservice);
         startservice=findViewById(R.id.start_service);

    }
}
